package com.such.kit.message.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.such.kit.validate.ValidateCommons;

/**
 * @author SUCH
 * <pre>
 * 消息项
 * 
 * 一个消息项传输一条数据处理时产生的消息
 * </pre>
 */
public class MessageItem<T> {

	/** originalBody：消息相关的原始对象 */
	private T originalBody;
	/** itemsResult：唯一标识 */
	private String key;
	/** title：消息描述 */
	private String title;
	/** status：状态码 */
	private String status;
	/** statusDescr：状态码描述 */
	private String statusDescr;
	/** contents：消息详细集 */
	private List<String> contents;

	public MessageItem(T originalBody, String status) {
		this(originalBody, "", status);
	}

	public MessageItem(T originalBody, String status, List<String> contents) {
		this(originalBody, "", status, contents);
	}

	public MessageItem(T originalBody, String title, String status) {
		this(originalBody, title, status, "");
	}

	public MessageItem(T originalBody, String title, String status, List<String> contents) {
		this(originalBody, title, status, "", contents);
	}

	public MessageItem(T originalBody, String title, String status, String statusDescr) {
		this(originalBody, UUID.randomUUID().toString(), title, status, statusDescr);
	}

	public MessageItem(T originalBody, String title, String status, String statusDescr, List<String> contents) {
		this(originalBody, UUID.randomUUID().toString(), title, status, statusDescr, contents);
	}

	public MessageItem(T originalBody, String key, String title, String status, String statusDescr) {
		this(originalBody, key, title, status, statusDescr, null);
	}

	public MessageItem(T originalBody, String key, String title, String status, String statusDescr, List<String> contents) {
		this.originalBody = originalBody;
		this.key = key;
		this.title = title;
		this.status = status;
		this.statusDescr = statusDescr;
		this.contents = contents;
	}

	public T getOriginalBody() {
		return this.originalBody;
	}

	public void setOriginalBody(T originalBody) {
		this.originalBody = originalBody;
	}

	public String getKey() {
		return this.key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getStatusDescr() {
		return this.statusDescr;
	}

	public void setStatusDescr(String statusDescr) {
		this.statusDescr = statusDescr;
	}

	public List<String> getContents() {
		if (ValidateCommons.isEmpty(this.contents)) {
			this.contents = new ArrayList<String>();
		}
		return this.contents;
	}

	public void setContents(List<String> contents) {
		this.contents = contents;
	}

	public void addContent(String content) {
		getContents().add(content);
	}

}
